home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / ru04.arj / READXGF.PAS < prev    next >
Pascal/Delphi Source File  |  1994-02-10  |  2KB  |  72 lines

  1. (* ******************************************************************** *)
  2. (* readxgf.pas For Turbo Pascal - Demonstrates how to display XGF files *)
  3. (*                                that are 64K or less. Use disxgf.c    *)
  4. (*                                for files that are greater than 64K   *)
  5. (*                                                                      *)
  6. (* Use Raster Clip/Rastport to convert PCX files to XGF format.         *)
  7. (*                                                                      *)
  8. (* ******************************************************************** *)
  9.  
  10. Program readxgf;
  11.   uses crt,graph;
  12.  
  13. {$F+}
  14. Function DetectVGA256 : integer;
  15. begin
  16.     DetectVGA256:=0;
  17. end;
  18. {$F-}
  19.  
  20.  
  21. Procedure setVGA256;
  22. Var
  23.  gd,gm : Integer;
  24. begin
  25.  gd:=InstallUserDriver('svga256',@detectvga256);
  26.  gd:=Detect;
  27.  Initgraph(gd,gm,'');
  28. end;
  29.  
  30.  
  31. Procedure setvga16;
  32. var
  33.  gd,gm : integer;
  34. begin
  35.  gd:=VGA;
  36.  gm:=VGALO;
  37.  
  38.  initgraph(gd, gm, '');
  39. end;
  40.  
  41. Procedure read_xgf(x,y : Word; filename : string);
  42. var
  43.  F : File;
  44.  imgBuf : Pointer;
  45.  size   : word;
  46.  error  : word;
  47. begin
  48. {$I-}
  49.  Assign(F,filename);
  50.  Reset(F,1);
  51.  error:=IORESULT;
  52.  if (error=0) then
  53.  begin
  54.    size:=filesize(F);
  55.    getmem(imgbuf,size);
  56.    blockread(F,imgBuf^,size);
  57.    close(F);
  58.    putimage(x,y,imgBuf^,NormalPut);
  59.    freemem(imgBuf,size);
  60.  end;
  61. {$I-}
  62. end;
  63.  
  64. begin
  65.   setvga16;          (* replace with setvga256 for 256 color XGF files *)
  66.   setfillstyle(SOLIDFILL,BLUE);
  67.   bar(0,0,getmaxx,getmaxy);
  68.   read_xgf(0,0,'image2.xgf');
  69.   repeat until keypressed;
  70.   closegraph;
  71. end.
  72.